<?php

namespace App\Jobs;

use App\Services\Api\PushService;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Log;
/**
 * 异步发送消息通知
 * @author chengzhigang
 * @time 2020/7/1 13:43
 * @package App\Jobs
 */
class AsyncSendMsgNotice implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    protected $msgData;//消息内容
    protected $user;//推送人员
    public function __construct($msgData,$user=[],$delay=1)
    {
        $this -> msgData = $msgData;
        $this -> user = $user;
        $this->delay($delay);//延迟多少秒执行
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $pushService = new PushService();
        $a = 1;
        throw new \Exception('报错了啦啦啦啦');
//        $result = $pushService->push($this -> msgData,$this -> msgData['user_type'],$this -> user);
    }
}
